Skip to content

AWS X-Ray Remote Sampler Part 2 - Add Rules Caching, Rules Matching Logic, Rate Limiter, and Sampling Targets Poller#3761

Open
jj22ee wants to merge 10 commits intoopen-telemetry:mainfrom
jj22ee:xray-sampler-pr1
Open

AWS X-Ray Remote Sampler Part 2 - Add Rules Caching, Rules Matching Logic, Rate Limiter, and Sampling Targets Poller#3761
jj22ee wants to merge 10 commits intoopen-telemetry:mainfrom
jj22ee:xray-sampler-pr1

Conversation

@jj22ee
Copy link
Copy Markdown
Contributor

@jj22ee jj22ee commented Sep 16, 2025

Description

Changes:

  • Add Sampling RuleCache
    • Caches a list of _SamplingRuleAppliers, ordered by rule priority then rule name. Each Rule Applier corresponds to the Sampling Rule from GetSamplingRules. Each call to GetSamplingRules will only update the Rules that have changed properties, to preserve the state of unchanged rules. This means Reservoir and Statistics will persist in Rules for unchanged rules.
    • The RuleCache will determine which Rule a set of {resource, attributes} matches with that has highest priority.
  • Added logic to fetch sampling targets for each _SamplingRuleApplier.
    • The sampling targets are periodically fetched every 10 seconds by making the GetSamplingTargets API call to X-Ray.
    • The targets determine the reservoir quota and the rate at which a _SamplingRuleApplier will sample the requests.
    • Each rule applier keeps and updates a sampling statistics document which is required in GetSamplingTargets call to determine the next target
  • Update _SamplingRuleApplier to perform Fixed Rate & Reservoir Sampling, and to include a method to apply matching logic against a set of {resource, attributes} by using the wild card and attribute matching from Utils
  • Added a _RateLimitingSampler (applied before the fixed rate sampler) to be used in each rule applier.
    • Together these samplers determine how many requests to sample every second and what percentage of additional requests to sample in that second.
  • Added class for FallbackSampler, a combination of _RateLimitingSampler and TraceIdRatioBased samplers to sample 1 req/sec and 5% of additional requests in that second.
  • Update _InternalAwsXRayRemoteSampler to depend on RuleCache and a FallbackSampler Sampler for making sampling decisions

Fixes #3305 -- This is the final PR to support X-Ray Remote Sampling.

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

Does This PR Require a Core Repo Change?

  • No.

Checklist:

See contributing.md for styleguide, changelog guidelines, and more.

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

@jj22ee jj22ee requested a review from a team as a code owner September 16, 2025 20:36
@xrmx xrmx moved this to Ready for review in Python PR digest Sep 17, 2025
Comment thread CHANGELOG.md Outdated
Copy link
Copy Markdown
Contributor

@xrmx xrmx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please add the following and take care of any eventual output of tox -e typecheck?

diff --git a/pyproject.toml b/pyproject.toml
index 30ada5bb2..45b8ea632 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -206,6 +206,7 @@ include = [
   "instrumentation-genai/opentelemetry-instrumentation-weaviate",
   "util/opentelemetry-util-genai",
   "exporter/opentelemetry-exporter-credential-provider-gcp",
+  "sdk-extension/opentelemetry-sdk-extension-aws/src/opentelemetry/sdk/extension/aws/trace/sampler",
 ]
 # We should also add type hints to the test suite - It helps on finding bugs.
 # We are excluding for now because it's easier, and more important to add to the instrumentation packages.

@jj22ee
Copy link
Copy Markdown
Contributor Author

jj22ee commented Nov 3, 2025

Made changes needed to make tox -e typecheck pass.

@github-actions
Copy link
Copy Markdown

This PR has been automatically marked as stale because it has not had any activity for 14 days. It will be closed if no further activity occurs within 14 days of this comment.
If you're still working on this, please add a comment or push new commits.

@github-actions github-actions Bot added the Stale label Mar 17, 2026
@github-actions github-actions Bot removed the Stale label Mar 21, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 4, 2026

This PR has been automatically marked as stale because it has not had any activity for 14 days. It will be closed if no further activity occurs within 14 days of this comment.
If you're still working on this, please add a comment or push new commits.

@github-actions github-actions Bot added the Stale label Apr 4, 2026
@github-actions
Copy link
Copy Markdown

This PR has been closed due to inactivity. Please reopen if you would like to continue working on it.

@jj22ee
Copy link
Copy Markdown
Contributor Author

jj22ee commented Apr 30, 2026

Seems I can't re-open the PR. Can a maintainer help re-open this? @xrmx @tammy-baylis-swi
Let me know if I should just create a new PR instead.

@xrmx xrmx reopened this May 4, 2026
@xrmx
Copy link
Copy Markdown
Contributor

xrmx commented May 4, 2026

@jj22ee done

@xrmx xrmx moved this from Done to Ready for review in Python PR digest May 4, 2026
@github-actions github-actions Bot removed the Stale label May 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Ready for review

Development

Successfully merging this pull request may close these issues.

Support for AWS X-Ray Remote Sampling

4 participants